package bishiqiangxun;
import java.util.*;
public class Test1 {
   //题目 : 笔试强训 day30 第一题  爱吃素
   //就是考察怎么求素数
   public static void main(String[] args) {
       Scanner in = new Scanner(System.in);
       //先输入
       int T = in.nextInt();


       for(int i = 0; i < T; i++) {
           long a = in.nextLong();
           long b = in.nextLong();

           if(isSuShu(a*b) == false) {
               System.out.println("NO");
           }else {
               System.out.println("YES");
           }

       }
   }
    private static boolean isSuShu(long c) {
        if(c <= 1) {
            return false;
        }
        for(long i = 2; i * i <= c; i++) {
            if(c % i == 0) {
                return false;
            }
        }
        return true;
    }
}
